﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper;
using Weight.Base;

namespace Weight.Dal.Base
{
    public class DalDbConnCheck
    {
        public async Task<bool> DbConnIsOk()
        {
            return await Task.Run(() =>
            {
                try
                {
                    using (IDbConnection conn = SessionFactory.CreateConnection())
                    {
                        if (conn.State == ConnectionState.Open)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
                catch(Exception ex)
                {
                    return false;
                }
               
            });
           
        }
    }
}
